﻿using CuaHangLego.DataAccess;
using CuaHangLego.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CuaHangLego.Webform.Controls
{
    public partial class FilterBar : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            IList<int> l = Session["recentItems"] as IList<int>;
            if (l != null)
            {
                l = l.Reverse().ToList();
                IList<SanPham> l2 = new List<SanPham>();
                foreach (int i in l)
                {
                    l2.Add(SanPhamDA.Instance.GetByID(i));
                }
                recentItems.DataSource = l2;
                recentItems.DataBind();
            }
        }

        protected void recentItems_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
                string ID = ((HiddenField)e.Item.FindControl("ProductID")).Value;
                ((HyperLink)e.Item.FindControl("ProductLink")).NavigateUrl = "~/ProductDetail.aspx?ID=" + ID;

            }
        }
    }
}